﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Headlight.Model;
using System.Data.Entity;

namespace Headlight.Domain.Repositories
{
    public class VehicleRepository
    {
        private EFDbContext context = new EFDbContext();

        public IQueryable<Vehicle> Vehicles
        {
            get { return context.Vehicles; }
        }

        public void SaveVehicle(Vehicle vehicle)
        {
            if (vehicle.VehicleID == 0)
            {
                context.Vehicles.Add(vehicle);
            }
            context.SaveChanges();
        }

        public void DeleteVehicle(Vehicle vehicle)
        {
            context.Vehicles.Remove(vehicle);
            context.SaveChanges();
        }
    }
}